// consulting.js：咨询师管理API
import request from '@/utils/request'

// 获取咨询师分页列表
export function getConsultantPage(params = {}) {
    const payload = {
        page: params?.page ?? 0,
        pageSize: params?.pageSize ?? 10,
        status: params?.status ?? 0,
        specialization: params?.specialization ?? '',
        consultationMode: params?.consultationMode ?? '',
        minPrice: params?.minPrice ?? '',
        maxPrice: params?.maxPrice ?? '',
        serviceArea: params?.serviceArea ?? '',
        keyWords: params?.keyWords ?? ''
    }

    payload.page = Math.max(1, parseInt(payload.page) || 1)
    payload.pageSize = Math.max(1, parseInt(payload.pageSize) || 10)

    // 清理空串/零值（按文档均为可选，空则不传）
    Object.keys(payload).forEach(k => {
        if (payload[k] === '' || payload[k] === null || payload[k] === undefined) {
            delete payload[k]
        }
    })

    return request.post('/management/consulting/page', payload)
}

// 获取咨询师的详细信息
export function getCounselorDetail(counselorUid) {
    return request.get('/management/consulting/detail', {
        params: {
            counselorUid
        }
    })
}

// 审核咨询师
// status: 1-通过审核, 2-审核未通过, 3-封禁
export function checkCounselor(data) {
    const payload = {
        id: data.id,
        type: 4, // 4代表咨询师
        reviewMessage: data.reviewMessage,
        status: data.status
    }
    return request.post('/management/consulting/checked', payload)
}


